package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	outputFile, err := os.OpenFile("test.txt", os.O_WRONLY|os.O_CREATE, 0666)
	if err != nil {
		fmt.Println("ERROR", err)
		return
	}
	defer outputFile.Close()
	outputWriter := bufio.NewWriter(outputFile)
	outputString := "Hello World! "
	for i := 0; i < 10; i++ {
		outputWriter.WriteString(outputString + strconv.Itoa(i) + "\n")
	}
	outputWriter.Flush()  // 强制刷新，保存到磁盘
}
